//
//  UserFeedBackController.m
//  takeout
//
//  Created by Mac on 12-1-7.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "UserFeedBackController.h"
#import "MoreManager.h"

@implementation UserFeedBackController
@synthesize textView;

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    self.title = @"意见反馈";
    UIView *tmpView = [[UIView alloc] init];
    self.view = tmpView;
    [tmpView release];
    
    UITextView *tmpTextView = [[UITextView alloc] initWithFrame:CGRectMake(40, 40, 250, 100)];
    textView = tmpTextView;
    
    [textView setBackgroundColor:[UIColor grayColor]];
    [self.view addSubview:textView];
    [tmpTextView release];
    
    UIButton *okBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [okBtn setFrame:CGRectMake(40, 160, 80, 40)];
    [okBtn addTarget:self action:@selector(sendReport:) forControlEvents:UIControlEventTouchUpInside];
    [okBtn setTitle:@"保存" forState:UIControlStateNormal]; 
    [self.view addSubview:okBtn];
    
    UIButton *cancelBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [cancelBtn setFrame:CGRectMake(140, 160, 80, 40)];
    [cancelBtn addTarget:self action:@selector(sendReport:) forControlEvents:UIControlEventTouchUpInside];
    [cancelBtn setTitle:@"取消" forState:UIControlStateNormal]; 
    [self.view addSubview:cancelBtn];
    
    [super viewDidLoad];

    
    // Do any additional setup after loading the view from its nib.
}

- (IBAction)sendReport:(id)sender{
    [self.textView resignFirstResponder];
    MoreManager *manager = [[MoreManager alloc] init];
    if ([manager sendFeedBack:self.textView.text]) {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:@"发送成功" delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
        [alertView show];
        [alertView release];
        [manager release];
        return;
    }
    [manager release];
}

- (IBAction)cancel:(id)sender{
    NSLog(@"click cancel");
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
